package com;

import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @ClassName SchedulerJob
 * @Description TODO
 * @Author zhuchen216628
 * @Date 2018/10/10 10:32
 * @Version 1.0
 **/

@Service
public class SchedulerJob {

    @Resource(name = "executorWithPoolSizeRange")
    private ThreadPoolTaskExecutor executor;

    @Scheduled(cron = "*/1 * * * * ?")
    public void doSchedule() {
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("current scheduler executor status:");
        stringBuilder.append(" - CurrentPoolSize : ").append(executor.getPoolSize());
        stringBuilder.append(" - MaximumPoolSize : ").append(executor.getMaxPoolSize());
        stringBuilder.append(" - ActiveTaskCount : ").append(executor.getActiveCount());
        System.out.println(stringBuilder.toString());
        String[] dd = new String[3];
        boolean equals = dd.equals("");
    }

    public static void main(String[] args) {
        ClassPathXmlApplicationContext context =
                new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
        while (true) {

        }
    }
}
